package com.race;

/**
 * Created by iss on 2018/3/27.
 */
public class LinkList {

    static class Node {
        private int data;
        private Node next;

        public Node() {
        }

        public Node(int data) {
            this.data = data;
        }

        public Node(int data, Node next) {
            this.data = data;
            this.next = next;
        }
    }

    static void printReverse(Node head) {
        if (head.next == null) {
            System.out.println(head.data);
        } else {
            printReverse(head.next);
            System.out.println(head.data);
        }
    }

    public static void main(String[] args) {
        Node head = new Node(1);
        Node node2 = new Node(2);
        head.next = node2;
        Node node3 = new Node(3);
        node2.next = node3;
        Node node4 = new Node(4);
        node3.next = node4;
        Node node5 = new Node(5);
        node4.next = node5;
        Node node6 = new Node(6);
        node5.next = node6;
        Node node7 = new Node(7);
        node6.next = node7;

        printReverse(head);
    }

}
